var data = {

  themes: [{ id: 0, name: '推荐', icon: 'camerafill', index: 0 }, { id: 1, name: '摄影', icon: 'camerafill', index: 0 }, { id: 2, name: '视频', icon: 'upstagefill', index: 1 }, { id: 4, name: '直播', icon: 'clothesfill', index: 2 }, { id: 5, name: '果蔬知识', icon: 'clothesfill', index: 2 },{ id: 6, name: '农户介绍', icon: 'clothesfill', index: 2 }],
  items: [{
    "images": [{
      "url": "https://www.agri35.com/UploadFiles/img_1_311565120_1138813349_26.jpg"
    }],
    frontImage: { url: 'https://www.agri35.com/UploadFiles/img_1_311565120_1138813349_26.jpg', width: '640', height: '640' },
    "themeIcon": "camerafill",
    "publishDate": "2021年2月5日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "17",
    "hitsNum": 237,
    "title": "蔬果拼盘，简单易做。蔬果拼盘，果蔬变身。",
    "category": "摄影",
    "conmentNum": 993,
    "likeNum": 809,
    "tags": ["摄影", "果蔬拼盘"]
  }, {
    "images": [{
      "url": "http://file.youboy.com/a/127/83/90/6/20548586.jpg"
    }, {
      "url": "http://www.qhnews.com/pic/0/01/20/27/1202783_637021.jpg"
    }],
      frontImage: { url: 'http://file.youboy.com/a/127/83/90/6/20548586.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2021年2月4日",
    "themeId": "1",
    "isRecommend": "1",
    "id": "16",
    "hitsNum": 804,
      "title": "理光GR2|闽南老市场|复古色调蔬果🤓",
    "category": "摄影",
    "conmentNum": 198,
    "likeNum": 308,
    "tags": ["闽南", "老市场"]
  }, {
    "images": [{
      "url": "https://img2.soyoung.com/tieba/android/post/20200605/9/2b92ec33b8f6b171b360182b22bd590b.jpg"
    }],
      frontImage: { url: 'https://img2.soyoung.com/tieba/android/post/20200605/9/2b92ec33b8f6b171b360182b22bd590b.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2021年6月7日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "15",
    "hitsNum": 306,
    "title": "亲测好喝的夏天减肥果汁！美白又减脂！",
    "category": "摄影",
    "conmentNum": 63,
    "likeNum": 452,
    "tags": ["果汁", "减肥"]
  }, {
    "images": [{
      "url": "http://img56.nongjx.com/9/20140805/635428308303518347679.jpg"
    }],
      frontImage: { url: 'http://img56.nongjx.com/9/20140805/635428308303518347679.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2021年3月15日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "13",
    "hitsNum": 148,
    "title": "‘e棵菜’不生产果蔬，我们只是果蔬的搬运工",
    "category": "摄影",
    "conmentNum": 723, 
    "likeNum": 551,
    "tags": ["新鲜", "农场"]
  }, {
    "images": [{
      "url": "https://ftp.bmp.ovh/imgs/2021/05/2b01ac2c72b3ee80.jpg"
    }],
      frontImage: { url: 'https://ftp.bmp.ovh/imgs/2021/05/2b01ac2c72b3ee80.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2021年6月6日",
    "themeId": "1",
    "isRecommend": "1",
    "id": "21",
    "hitsNum": 986,
    "title": "手绘书签|蔬果系列，种瓜得瓜",
    "category": "摄影",
    "conmentNum": 396,
    "likeNum": 155,
    "tags": ["手绘书签", "蔬果系列"]
  }, {
    "images": [{
      "url": "https://picnew14.photophoto.cn/20200711/shengnvguo-38011702_1.jpg"
    }, {
      "url": "http://imgs.bzw315.com/UploadFiles/Version2/0/20160929/201609291023188177.jpg"
    }, {
      "url": "http://pic44.photophoto.cn/20170708/0012024988566694_b.jpg"
    }],
      frontImage: { url: 'https://picnew14.photophoto.cn/20200711/shengnvguo-38011702_1.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2021年5月30日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "20",
    "hitsNum": 316,
    "title": "治愈系鲜果-阳光圣女果",
    "category": "摄影",
    "conmentNum": 882,
    "likeNum": 212,
    "tags": ["治愈系", "圣女果"]
  }, {
    "images": [{
      "url": "http://5b0988e595225.cdn.sohucs.com/images/20190511/e172269acf504b7c80c9e29da5881270.jpeg"
    }],
      frontImage: { url: 'http://5b0988e595225.cdn.sohucs.com/images/20190511/e172269acf504b7c80c9e29da5881270.jpeg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2021年3月1日",
    "themeId": "1",
    "isRecommend": "1",
    "id": "12",
    "hitsNum": 669,
    "title": "我只为你绽放在冬夜，农场田园瓜果",
    "category": "摄影",
    "conmentNum": 80,
    "likeNum": 293,
    "tags": ["农场", "瓜果"]
  },   {
    "images": [{
      "url": "http://ci.xiaohongshu.com/89df80a7-2a88-474c-9fd8-00fcd2cab006"
    }, {
      "url": "http://ci.xiaohongshu.com/ce23ff81-d7b1-450d-8ca4-c1442ee6a13a"
    }, {
      "url": "http://ci.xiaohongshu.com/ce23ff81-d7b1-450d-8ca4-c1442ee6a13a"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/89df80a7-2a88-474c-9fd8-00fcd2cab006@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2021年4月15日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "19",
    "hitsNum": 427,
    "title": "刚买完相机，第二天就去了解这个世界，全程P档见啥就拍",
    "category": "摄影",
    "conmentNum": 926,
    "likeNum": 860,
      "tags": ["若尔盖草原"]
  }, {
      "images": [{
        "url": "http://ci.xiaohongshu.com/f4ef2193-44fe-4b9a-8814-1b97ef033301"
      }, {
        "url": "http://ci.xiaohongshu.com/537204b8-2086-426a-9fd5-a08b4e7d41ce"
      }],
      frontImage: { url: 'http://ci.xiaohongshu.com/f4ef2193-44fe-4b9a-8814-1b97ef033301@r_640w_640h.jpg', width: '200', height: '300' },
      "themeIcon": "camerafill",
      "publishDate": "2019年10月5日",
      "themeId": "1",
      "isRecommend": "1",
      "id": "2",
      "hitsNum": 334,
      "title": "新都桥摄影的天堂，我只取那一朵",
      "category": "摄影",
      "conmentNum": 644,
      "likeNum": 463,
      "tags": ["新都桥", "格桑花"]
    }, {
      "images": [{
        "url": "https://photo.tuchong.com/6644602/f/555534720.jpg"
      }],
      frontImage: { url: 'https://photo.tuchong.com/6644602/f/555534720.jpg', width: '200', height: '300' },
      "themeIcon": "camerafill",
      "publishDate": "2021年2月12日",
      "themeId": "1",
      "isRecommend": "1",
      "id": "3",
      "hitsNum": 924,
      "title": "我向往的田园生活",
      "category": "摄影",
      "conmentNum": 382,
      "likeNum": 300,
      "tags": ["田园生活", "蓝天"]
    }, {
      "images": [{
        "url": "http://ci.xiaohongshu.com/2b6d1916-6289-45ad-b78a-9da962cce47e"
      }],
      frontImage: { url: 'http://ci.xiaohongshu.com/2b6d1916-6289-45ad-b78a-9da962cce47e@r_640w_640h.jpg', width: '200', height: '300' },
      "themeIcon": "camerafill",
      "publishDate": "2021年2月12日",
      "themeId": "1",
      "id": "4",
      "hitsNum": 150,
      "title": "安安静静，置身事外，看着平静的湖面发呆",
      "category": "摄影",
      "conmentNum": 512,
      "likeNum": 670,
      "tags": ["哈尔滨", "蓝天"]
    }]
}

function getData(pageNo, type) {
  var result = {};
  result.themes = data.themes;

  var itemType = type||data.themes[0].id;
  var contents = [];
  if (itemType == 0) {
    contents = data.items.filter(item => item.isRecommend == 1);
  } else {
    contents = data.items.filter(item => item.themeId == itemType);
  }

  var offset = (pageNo - 1) * 6;
  result.items = (offset + 6 >= contents.length) ? contents.slice(offset, contents.length) : contents.slice(offset, offset + 6);
  return result;
}

function getItemById(id) {
  var itemObject = {};
  data.items.forEach(function (item, index, array) {
    if (item.id == id) {
      itemObject = item;
    }
  })
  return itemObject;
}

module.exports = {
  getData: getData,
  getItemById: getItemById
}
